import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SupplierMasterVO, SupplierMasterForm, SupplierMasterQuery } from '@/api/manu/supplierMaster/types';

/**
 * 查询供应商主数据列表
 * @param query
 * @returns {*}
 */

export const listSupplierMaster = (query?: SupplierMasterQuery): AxiosPromise<SupplierMasterVO[]> => {
  return request({
    url: '/manu/supplierMaster/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应商主数据详细
 * @param id
 */
export const getSupplierMaster = (id: string | number): AxiosPromise<SupplierMasterVO> => {
  return request({
    url: '/manu/supplierMaster/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商主数据
 * @param data
 */
export const addSupplierMaster = (data: SupplierMasterForm) => {
  return request({
    url: '/manu/supplierMaster',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商主数据
 * @param data
 */
export const updateSupplierMaster = (data: SupplierMasterForm) => {
  return request({
    url: '/manu/supplierMaster',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商主数据
 * @param id
 */
export const delSupplierMaster = (id: string | number | Array<string | number>) => {
  return request({
    url: '/manu/supplierMaster/' + id,
    method: 'delete'
  });
};
